import 'package:finance_app/src/entities/employee_contact_entity.dart';

employeeContactEntityFromJson(EmployeeContactEntity data, Map<String, dynamic> json) {
	if (json['data_type'] != null) {
		data.dataType = json['data_type'].toString();
	}
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['company_id'] != null) {
		data.companyId = json['company_id'] is String
				? int.tryParse(json['company_id'])
				: json['company_id'].toInt();
	}
	if (json['user_id'] != null) {
		data.userId = json['user_id'] is String
				? int.tryParse(json['user_id'])
				: json['user_id'].toInt();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['title'] != null) {
		data.title = json['title'].toString();
	}
	if (json['nationality'] != null) {
		data.nationality = json['nationality'].toString();
	}
	if (json['race'] != null) {
		data.race = json['race'].toString();
	}
	if (json['martial_status'] != null) {
		data.martialStatus = json['martial_status'].toString();
	}
	if (json['pass_type'] != null) {
		data.passType = json['pass_type'].toString();
	}
	if (json['pr_started_at'] != null) {
		data.prStartedAt = json['pr_started_at'];
	}
	if (json['gender'] != null) {
		data.gender = json['gender'].toString();
	}
	if (json['gender_name'] != null) {
		data.genderName = json['gender_name'].toString();
	}
	if (json['dob'] != null) {
		data.dob = json['dob'].toString();
	}
	if (json['identity_number'] != null) {
		data.identityNumber = json['identity_number'].toString();
	}
	if (json['employee_number'] != null) {
		data.employeeNumber = json['employee_number'].toString();
	}
	if (json['employment_type'] != null) {
		data.employmentType = json['employment_type'].toString();
	}
	if (json['salary_period'] != null) {
		data.salaryPeriod = json['salary_period'].toString();
	}
	if (json['income_data'] != null) {
		data.incomeData = (json['income_data'] as List).map((v) => EmployeeContactIncomeData().fromJson(v)).toList();
	}
	if (json['deduction_data'] != null) {
		data.deductionData = (json['deduction_data'] as List).map((v) => EmployeeContactDeductionData().fromJson(v)).toList();
	}
	if (json['leave_data'] != null) {
		data.leaveData = (json['leave_data'] as List).map((v) => EmployeeContactLeaveData().fromJson(v)).toList();
	}
	if (json['working_days_count'] != null) {
		data.workingDaysCount = json['working_days_count'] is String
				? num.tryParse(json['working_days_count'])
				: json['working_days_count'];
	}
	if (json['working_days'] != null) {
		data.workingDays = (json['working_days'] as List).map((v) => WorkingDayData().fromJson(v)).toList();
	}
	if (json['worker_levy'] != null) {
		data.workerLevy = json['worker_levy'].toString();
	}
	if (json['employee_leaves'] != null) {
		data.employeeLeaves = (json['employee_leaves'] as List).map((v) => EmployeeContactEmployeeLeaves().fromJson(v)).toList();
	}
	if (json['joined_at'] != null) {
		data.joinedAt = json['joined_at'];
	}
	if (json['confirmed_at'] != null) {
		data.confirmedAt = json['confirmed_at'];
	}
	if (json['country_code'] != null) {
		data.countryCode = json['country_code'].toString();
	}
	if (json['phone_number'] != null) {
		data.phoneNumber = json['phone_number'].toString();
	}
	if (json['email'] != null) {
		data.email = json['email'].toString();
	}
	if (json['is_director'] != null) {
		data.isDirector = json['is_director'] is String
				? int.tryParse(json['is_director'])
				: json['is_director'].toInt();
	}
	if (json['address_country'] != null) {
		data.addressCountry = json['address_country'].toString();
	}
	if (json['address_city'] != null) {
		data.addressCity = json['address_city'].toString();
	}
	if (json['address_postal_code'] != null) {
		data.addressPostalCode = json['address_postal_code'].toString();
	}
	if (json['address_line_1'] != null) {
		data.addressLine1 = json['address_line_1'].toString();
	}
	if (json['address_line_2'] != null) {
		data.addressLine2 = json['address_line_2'];
	}
	if (json['address_unit'] != null) {
		data.addressUnit = json['address_unit'].toString();
	}
	if (json['emergency_contact_name'] != null) {
		data.emergencyContactName = json['emergency_contact_name'];
	}
	if (json['emergency_contact_relationship'] != null) {
		data.emergencyContactRelationship = json['emergency_contact_relationship'];
	}
	if (json['emergency_contact_country_code'] != null) {
		data.emergencyContactCountryCode = json['emergency_contact_country_code'];
	}
	if (json['emergency_contact_phone_number'] != null) {
		data.emergencyContactPhoneNumber = json['emergency_contact_phone_number'];
	}
	if (json['bank_account_name'] != null) {
		data.bankAccountName = json['bank_account_name'].toString();
	}
	if (json['bank_account_number'] != null) {
		data.bankAccountNumber = json['bank_account_number'].toString();
	}
	if (json['bank_name'] != null) {
		data.bankName = json['bank_name'].toString();
	}
	if (json['bank_branch_name'] != null) {
		data.bankBranchName = json['bank_branch_name'].toString();
	}
	if (json['bank_branch_code'] != null) {
		data.bankBranchCode = json['bank_branch_code'].toString();
	}
	if (json['resigned_at'] != null) {
		data.resignedAt = json['resigned_at'];
	}
	if (json['is_completed'] != null) {
		data.isCompleted = json['is_completed'] is String
				? int.tryParse(json['is_completed'])
				: json['is_completed'].toInt();
	}
	if (json['action_count'] != null) {
		data.actionCount = json['action_count'] is String
				? int.tryParse(json['action_count'])
				: json['action_count'].toInt();
	}
	if (json['created_by'] != null) {
		data.createdBy = json['created_by'];
	}
	if (json['created_at'] != null) {
		data.createdAt = json['created_at'].toString();
	}
	if (json['updated_at'] != null) {
		data.updatedAt = json['updated_at'].toString();
	}
	if (json['contribution'] != null) {
		data.contribution = json['contribution'].toString();
	}
	if (json['contribution_amount'] != null) {
		data.contributionAmount = json['contribution_amount'].toString();
	}
	if (json['bank_code'] != null) {
		data.bankCode = json['bank_code'].toString();
	}
	if (json['identity_issued_at'] != null) {
		data.identityIssuedAt = json['identity_issued_at'].toString();
	}
	if (json['identity_expire_at'] != null) {
		data.identityExpireAt = json['identity_expire_at'].toString();
	}
	return data;
}

Map<String, dynamic> employeeContactEntityToJson(EmployeeContactEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['data_type'] = entity.dataType;
	data['id'] = entity.id;
	data['company_id'] = entity.companyId;
	data['user_id'] = entity.userId;
	data['name'] = entity.name;
	data['title'] = entity.title;
	data['nationality'] = entity.nationality;
	data['race'] = entity.race;
	data['martial_status'] = entity.martialStatus;
	data['pass_type'] = entity.passType;
	data['pr_started_at'] = entity.prStartedAt;
	data['gender'] = entity.gender;
	data['gender_name'] = entity.genderName;
	data['dob'] = entity.dob;
	data['identity_number'] = entity.identityNumber;
	data['employee_number'] = entity.employeeNumber;
	data['employment_type'] = entity.employmentType;
	data['salary_period'] = entity.salaryPeriod;
	data['income_data'] =  entity.incomeData?.map((v) => v.toJson())?.toList();
	data['deduction_data'] =  entity.deductionData?.map((v) => v.toJson())?.toList();
	data['leave_data'] =  entity.leaveData?.map((v) => v.toJson())?.toList();
	data['working_days_count'] = entity.workingDaysCount;
	data['working_days'] =  entity.workingDays?.map((v) => v.toJson())?.toList();
	data['worker_levy'] = entity.workerLevy;
	data['employee_leaves'] =  entity.employeeLeaves?.map((v) => v.toJson())?.toList();
	data['joined_at'] = entity.joinedAt;
	data['confirmed_at'] = entity.confirmedAt;
	data['country_code'] = entity.countryCode;
	data['phone_number'] = entity.phoneNumber;
	data['email'] = entity.email;
	data['is_director'] = entity.isDirector;
	data['address_country'] = entity.addressCountry;
	data['address_city'] = entity.addressCity;
	data['address_postal_code'] = entity.addressPostalCode;
	data['address_line_1'] = entity.addressLine1;
	data['address_line_2'] = entity.addressLine2;
	data['address_unit'] = entity.addressUnit;
	data['emergency_contact_name'] = entity.emergencyContactName;
	data['emergency_contact_relationship'] = entity.emergencyContactRelationship;
	data['emergency_contact_country_code'] = entity.emergencyContactCountryCode;
	data['emergency_contact_phone_number'] = entity.emergencyContactPhoneNumber;
	data['bank_account_name'] = entity.bankAccountName;
	data['bank_account_number'] = entity.bankAccountNumber;
	data['bank_name'] = entity.bankName;
	data['bank_branch_name'] = entity.bankBranchName;
	data['bank_branch_code'] = entity.bankBranchCode;
	data['resigned_at'] = entity.resignedAt;
	data['is_completed'] = entity.isCompleted;
	data['action_count'] = entity.actionCount;
	data['created_by'] = entity.createdBy;
	data['created_at'] = entity.createdAt;
	data['updated_at'] = entity.updatedAt;
	data['contribution'] = entity.contribution;
	data['contribution_amount'] = entity.contributionAmount;
	data['bank_code'] = entity.bankCode;
	data['identity_issued_at'] = entity.identityIssuedAt;
	data['identity_expire_at'] = entity.identityExpireAt;
	return data;
}

employeeContactIncomeDataFromJson(EmployeeContactIncomeData data, Map<String, dynamic> json) {
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['amount'] != null) {
		data.amount = json['amount'] is String
				? num.tryParse(json['amount'])
				: json['amount'];
	}
	if (json['currency_code'] != null) {
		data.currencyCode = json['currency_code'].toString();
	}
	if (json['cpf_payable'] != null) {
		data.cpfPayable = json['cpf_payable'] is String
				? int.tryParse(json['cpf_payable'])
				: json['cpf_payable'].toInt();
	}
	if (json['wage_type'] != null) {
		data.wageType = json['wage_type'].toString();
	}
	return data;
}

Map<String, dynamic> employeeContactIncomeDataToJson(EmployeeContactIncomeData entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['name'] = entity.name;
	data['amount'] = entity.amount;
	data['currency_code'] = entity.currencyCode;
	data['cpf_payable'] = entity.cpfPayable;
	data['wage_type'] = entity.wageType;
	return data;
}

employeeContactDeductionDataFromJson(EmployeeContactDeductionData data, Map<String, dynamic> json) {
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['amount'] != null) {
		data.amount = json['amount'] is String
				? num.tryParse(json['amount'])
				: json['amount'];
	}
	if (json['currency_code'] != null) {
		data.currencyCode = json['currency_code'].toString();
	}
	return data;
}

Map<String, dynamic> employeeContactDeductionDataToJson(EmployeeContactDeductionData entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['name'] = entity.name;
	data['amount'] = entity.amount;
	data['currency_code'] = entity.currencyCode;
	return data;
}

employeeContactLeaveDataFromJson(EmployeeContactLeaveData data, Map<String, dynamic> json) {
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['amount'] != null) {
		data.amount = json['amount'] is String
				? num.tryParse(json['amount'])
				: json['amount'];
	}
	return data;
}

Map<String, dynamic> employeeContactLeaveDataToJson(EmployeeContactLeaveData entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['name'] = entity.name;
	data['amount'] = entity.amount;
	return data;
}

workingDayDataFromJson(WorkingDayData data, Map<String, dynamic> json) {
	if (json['is_working'] != null) {
		data.isWorking = json['is_working'] is String
				? int.tryParse(json['is_working'])
				: json['is_working'].toInt();
	}
	if (json['is_half_day'] != null) {
		data.isHalfDay = json['is_half_day'] is String
				? int.tryParse(json['is_half_day'])
				: json['is_half_day'].toInt();
	}
	return data;
}

Map<String, dynamic> workingDayDataToJson(WorkingDayData entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['is_working'] = entity.isWorking;
	data['is_half_day'] = entity.isHalfDay;
	return data;
}

employeeContactEmployeeLeavesFromJson(EmployeeContactEmployeeLeaves data, Map<String, dynamic> json) {
	if (json['data_type'] != null) {
		data.dataType = json['data_type'].toString();
	}
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['employee_id'] != null) {
		data.employeeId = json['employee_id'] is String
				? int.tryParse(json['employee_id'])
				: json['employee_id'].toInt();
	}
	if (json['year'] != null) {
		data.year = json['year'].toString();
	}
	if (json['type'] != null) {
		data.type = json['type'].toString();
	}
	if (json['amount'] != null) {
		data.amount = json['amount'] is String
				? num.tryParse(json['amount'])
				: json['amount'];
	}
	if (json['forward_amount'] != null) {
		data.forwardAmount = json['forward_amount'] is String
				? num.tryParse(json['forward_amount'])
				: json['forward_amount'];
	}
	if (json['total'] != null) {
		data.total = json['total'] is String
				? num.tryParse(json['total'])
				: json['total'];
	}
	if (json['used'] != null) {
		data.used = json['used'] is String
				? num.tryParse(json['used'])
				: json['used'];
	}
	if (json['status'] != null) {
		data.status = json['status'].toString();
	}
	if (json['created_at'] != null) {
		data.createdAt = json['created_at'].toString();
	}
	if (json['updated_at'] != null) {
		data.updatedAt = json['updated_at'].toString();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	return data;
}

Map<String, dynamic> employeeContactEmployeeLeavesToJson(EmployeeContactEmployeeLeaves entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['data_type'] = entity.dataType;
	data['id'] = entity.id;
	data['employee_id'] = entity.employeeId;
	data['year'] = entity.year;
	data['type'] = entity.type;
	data['amount'] = entity.amount;
	data['forward_amount'] = entity.forwardAmount;
	data['total'] = entity.total;
	data['used'] = entity.used;
	data['status'] = entity.status;
	data['created_at'] = entity.createdAt;
	data['updated_at'] = entity.updatedAt;
	data['name'] = entity.name;
	return data;
}